<?
define('_VIEW_MODEL_','default');
require_once './init.php';
header("Content-type:text/vnd.wap.wml;charset=utf-8");
$id = intval($id);
if(isset($act)&&$act == "update"){
	if($birth_year != 0000){
		$year = $birth_year;
		$mont = $birth_month;
		$day  = $birth_day;
		$tim  = mktime(0,0,0,$mont,$day,$year);
		//echo "update {$telper}user set `sex`='$gender',`birthday` = '$tim',`zodiac`='$sx',`const`='$stellation',`likebook`='$book',`sign`='$sign' where `id`='$id'";
		//exit;
		$db->Execute("update {$telper}user set `sex`='$gender',`birthday` = '$tim',`zodiac`='$sx',`const`='$stellation',`likebook`='$book',`sign`='$sign' where `id`='$id'");
		header("Location:bookhouse.php?id=$id");
	}else{
		header("Location:owninfo.php?id=$id&wrong=is");
		exit;
	}
}
$userinfo = $db->GetRow("select * from {$telper}user where `id` ='$id'");
$time  = time();
$yeararray =array();
$nowyear = date("Y",$time);
$year  = date("Y",$userinfo['birthday']);
$m     = date("m",$userinfo['birthday']);
$day   = date("d",$userinfo['birthday']);
$m   = intval($m);
for($i = 1950;$i<=$nowyear;$i++){
	$val = $year == $i?"selected='selected'":"";
	$yeararray[]= "<option value='".$i."' $val >$i</option>";
}
for($i=1;$i<=12;$i++){
		$val = $i==$m?"selected='selected'":"";
		$montharray[] = "<option value='".$i."' $val >$i</option>";
	}
if(!empty($m)){
	if($m==1||$m==3||$m==5||$m==7||$m==8||$m==10||$m==12){
		for($j=1;$j<=31;$j++){
			$val = $j == $day?"selected='selected'":"";
			$dayarray[] = "<option value='".$j."' $val >$j</option>";
		}
	}
	if($m==4||$m==6||$m==9||$m==11){
		for($j=1;$j<=30;$j++){
			$val = $j == $day?"selected='selected'":"";
			$dayarray[] = "<option value='".$j."' $val >$j</option>";
		}
	}
if ($year%100 && $year%400 || $year%100 != 0 && $year%4 ==0){
	if($m==2){
		for($j=1;$j<=29;$j++){
			$val = $j == $day?"selected='selected'":"";
			$dayarray[] = "<option value='".$j."' $val >$j</option>";
		}
	}
}else{
	if($m==2){
		for($j=1;$j<=28;$j++){
			$val = $j == $day?"selected='selected'":"";
			$dayarray[] = "<option value='".$j."' $val >$j</option>";
		}
	}
}}else{
	for($j=1;$j<=31;$j++){
			$dayarray[] = "<option value='".$j."' $val >$j</option>";
	}
}
if(!empty($userinfo['zodiac'])){
	foreach ($zomictyle as $k=>$v){
		$val = $userinfo['zodiac']== $k?"selected='selected'":"";
		$zoicarray[] = "<option value='".$k."' $val >$v</option>";
	}
}else{
	foreach ($zomictyle as $k=>$v){
		$zoicarray[] = "<option value='".$k."' >$v</option>";
	}
}
if(!empty($userinfo['const'])){
	foreach ($colmustyle as $k=>$v){
		$val = intval($userinfo['const'])== $k?"selected='selected'":"";
		$colmarray[] = "<option value='".$k."' $val >$v</option>";
	}
}else{
	foreach ($colmustyle as $k=>$v){
		$colmarray[] = "<option value='".$k."' >$v</option>";
	}
}
if(isset($wrong)&&!empty($wrong)){
	$stip = "输入错误，请重新输入!";
}
else{
	$stip = "";
}
//print_r($yeararray);
$smartyObj->assign("yeararray",$yeararray);
$smartyObj->assign("month",$montharray);
$smartyObj->assign("day",$dayarray);
$smartyObj->assign("stip",$stip);
$smartyObj->assign("zoicarray",$zoicarray);
$smartyObj->assign("colmarray",$colmarray);
$smartyObj->assign("userinfo",$userinfo);
$smartyObj->display("owninfo.tpl");
?>